package ModelLayer;
import java.util.ArrayList;
import java.util.Calendar;


public class Offer
   {
    
    private int offerId;
    private String date;
    private Customer offerCustomer;
    private ArrayList<OfferMaterial> offerMaterial;
    private ArrayList<OfferLabour> offerLabour;
    private int materials;
    private int customerId;
    private String contact;
    private String name;
    
    public Offer()
    {
    	offerMaterial = new ArrayList<OfferMaterial>();
        offerLabour = new ArrayList<OfferLabour>();
        materials = 1;
        contact = "none";
        name = "none";
    }
    public Offer(int offerId,int customerId, String date)
    {
        this.offerId = offerId;
        this.date = date;
        this.customerId = customerId;
        
        offerMaterial = new ArrayList<OfferMaterial>();
        offerLabour = new ArrayList<OfferLabour>();
    }

    public int getMaterials()
    {
    	return materials;
    }
    public int getOfferId()
    {
        return offerId;
    }
    
    public String getOfferDate()
    {
        return date;
    }
    
    public Customer getOfferCustomer()
    {
        return offerCustomer;
    }
    
    public ArrayList<OfferMaterial> getOfferMaterial()
    {
        return offerMaterial;
    }
    
   
    
    public void setOfferId(int id)
    {
        this.offerId = id;
    }
    
    public void setOfferCustomer(Customer offerCustomer)
    {
        this.offerCustomer = offerCustomer;
    }
    
    public void addOfferMaterial(OfferMaterial material)
    {
        offerMaterial.add(material);
    }
    
    public void addOfferLabour(double price, int amount, int labourId,String name, int offerLabourId)
    {
		OfferLabour offerLabourItems = new OfferLabour(price, amount, getOfferId(), labourId, name, offerLabourId);
		offerLabour.add(offerLabourItems);
	}
    
    public void removeOfferLabour(int labourId)
    {
		for(OfferLabour offLabour : offerLabour)
		{
			if(offLabour.getLabourId() == labourId) offerLabour.remove(offLabour);
		}
    }
		
	public ArrayList<OfferLabour> getOfferLabours()
		{
			return offerLabour;
		}
	
	public void addOfferMaterial(double price, int quantity,  String type, int materialId, String name,int offerMaterialId)
    {
		OfferMaterial offerMaterialItems = new OfferMaterial(price, quantity, getOfferId(), type, materialId, name, offerMaterialId);
		offerMaterial.add(offerMaterialItems);
	}
	
	   public void removeOfferMaterial(int materialId)
	    {
			for(OfferMaterial offLabour : offerMaterial)
			{
				if(offLabour.getMaterialId() == materialId) offerMaterial.remove(offLabour);
			}
	    }
	
	public int getCustomerId() {
		return customerId;
	}
	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}
	public String getContact() {
		return contact;
	}
	public void setContact(String contact) {
		this.contact = contact;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public void setDate(String date)
	{
		this.date=date;
	}
	public void setLabourItem(ArrayList<OfferLabour> offerLabour)
	{
		this.offerLabour = offerLabour;
	}
    
}
